package com.xlh.fgs;

import java.util.ArrayList;
import java.util.List;

import com.xlh.Utils.FUti;
import com.xlh.adapter.UserAttrAdapter;

import com.xlh.bean.ProtocolObject.HpInfo;
import com.xlh.bean.UserAttrBean;

import com.xlh.outside.R;

import com.xlh.view.roundcornerprogressbar.TextRoundCornerProgressBar;

import android.app.Fragment;

import android.os.Bundle;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.widget.AbsListView;
import android.widget.GridView;
import android.widget.LinearLayout;


public class UserFg extends Fragment {

	public int screenWidth;

	public boolean isSerColored() {
		return isSerColored;
	}

	public void setSerColored(boolean serColored) {
		isSerColored = serColored;
	}

	private boolean isSerColored = false;
	private boolean isCreateed = false;


	public UserFg( ) {
		// TODO Auto-generated constructor stub


	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
			// TODO Auto-generated method stub
			return inflater.inflate(R.layout.user_attr_gr_layout, container, false);
	}

	private TextRoundCornerProgressBar pb01,pb02,pb03;
	private GridView mGridView;
	private UserAttrAdapter adapter;
	private List<UserAttrBean> userAttrBeanLists = new ArrayList<UserAttrBean>();
	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		// TODO Auto-generated method stub

		mGridView = (GridView) view.findViewById(R.id.userAttrGridView);


		ViewGroup.LayoutParams  param = mGridView.getLayoutParams();

		param.height =FUti.dip2px(getActivity(), 40);

		mGridView.setLayoutParams(param);



		adapter = new UserAttrAdapter(getActivity(), userAttrBeanLists);
		adapter.notifyDataSetChanged();
		mGridView.setAdapter(adapter);

		this.isCreateed = true;

	}

	public void dealDatas(HpInfo hpInfo) {

		String temp,text="",colr="#FFFF6461";
		String[] tary;
		float ax=0,in=0,spi=0;

		if(!isCreateed) return;



		userAttrBeanLists.clear();

		for (int i = 0; i < hpInfo.getHp().size(); i++) {




			UserAttrBean userAttrBean = new UserAttrBean();
			userAttrBean.setHasTag( hpInfo.getHp().get(i).getTxt() );
			userAttrBean.setIn( Float.parseFloat(hpInfo.getHp().get(i).getMin()) );
			userAttrBean.setSpi( Float.parseFloat(hpInfo.getHp().get(i).getEff()));
			userAttrBean.setMax( Float.parseFloat(hpInfo.getHp().get(i).getMax()) );
			userAttrBean.setText(hpInfo.getHp().get(i).getTxt() );
			userAttrBean.setColor(hpInfo.getHp().get(i).getColor() );


			userAttrBeanLists.add(userAttrBean);

		}

		adapter.setData(userAttrBeanLists);


		if(!this.isSerColored){
			this.isSerColored = true;
		}



	}





	private List<TextRoundCornerProgressBar> wzmPbList = new ArrayList<TextRoundCornerProgressBar>();



}
